home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / graphics / jpeg2ps / jpeg2ps.txt < prev    next >
Text File  |  1999-12-06  |  15KB  |  339 lines

  1. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  2. jpeg2ps - convert JPEG compressed images to PostScript Level 2
  3.  
  4. jpeg2ps is available from http://www.ifconnection.de/~tm
  5. and many other sites, notably CTAN mirrors.
  6.  
  7. Copyright (C) 1994-99 Thomas Merz (tm@muc.de)
  8. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  9.  
  10. Purpose of jpeg2ps
  11. ==================
  12. jpeg2ps converts JPEG files to PostScript Level 2 or 3 EPS. In fact, jpeg2ps
  13. is not really a converter but a "wrapper": it reads the image parameters
  14. (width, height, number of color components) in a JPEG file, writes the
  15. according EPS header and then copies the compressed JPEG data to the output
  16. file. Decompression is done by the PostScript interpreter (only PostScript
  17. Level 2 and 3 interpreters support JPEG compression and decompression).
  18. If you have a slow communication channel and a fast printer, sending
  19. compressed image data is a big win.
  20.  
  21.  
  22. Change History
  23. ==============
  24.     
  25. V1.8 (July 28, 1999)
  26.   - Added -q option for suppressing all non-error messages.
  27.   - Don't use the supplied getopt on Unix by default, but still
  28.     include the source module in the distribution (and use it on
  29.     DOS/Windows)
  30.   - Added -p option for setting the page size on the command line.
  31.     If no such option is supplied, A4 or letter is used as default,
  32.     according to a compile time option. 
  33.   - Renamed makefile.gcc to the more common Makefile.
  34.   - Added casts to get rid of some warning messages.
  35.   - Added Mac support for use with DropUNIX. This required opening
  36.     the files in binary mode, properly initializing some statics,
  37.     and replacing the getopt loop with a plain argc loop (for now).
  38.  
  39. V1.7 (April 9, 1999)
  40.   - Fixed an omission in the Makefile (makefile.gcc)
  41.   - Removed the OS2 #ifdefs and made the conditional code identical to the
  42.     DOS code. Therefore, using -DDOS should also work on OS/2.
  43.  
  44. V1.6 (March 29, 1999)
  45.   - Changed all references to my old Web site to the current address
  46.     http://www.ifconnection.de/~tm
  47.   - Added support for OS/2, provided by
  48.     Stefan A. Deutscher (sad@utk.edu / stefand@ibm.net)
  49.   - Added support for VMS, provided by
  50.     Rolf Niepraschk (niepraschk@ptb.de)
  51.   - Changed the get_2bytes() macro in readjpeg.c to a static function
  52.     in order to avoid portability issues. Since the evaluation order
  53.     in the formely used macro version isn't guaranteed, the result
  54.     was garbled on some platforms, notably with the Metrowerks C
  55.     compilers for BeOS and Macintosh.
  56.   - Changed the auto rotate feature in order to produce "clean" (unrotated)
  57.     EPS files. The old feature of automatically rotating images to
  58.     landscape mode if width > height can be reactivated with the new
  59.     command line option "-a" (auto rotate)
  60.   - Changed the ASCII85 output routine in order to avoid two consecutive
  61.     percent characters at the beginning of a line. Although legal PostScript,
  62.     this may cause trouble with some post-processing programs, notably
  63.     when including jpeg2ps output in TeX files. This should fix the
  64.     problems dvips users sometimes encountered when using jpeg2ps.
  65.     The comment in this file (jpeg2ps.txt) regarding problems with
  66.     TeX PostScript drivers has been deleted.
  67.  
  68. V1.5 (Dec. 12, 1996)
  69.   - Included ASCIIHex encoding again (the code was already there,
  70.     only command line option added). This is primarily useful as as
  71.     workaround for a brain-damaged dvips "feature" (see below).
  72.   - Added note on dvips and tgif in jpeg2ps.txt.
  73.   - Removed jpeg2pdf again. Its functionality will be contained in the
  74.     forthcoming PDFlib C library and some library client programs.
  75.  
  76. V1.4 (Aug. 19, 1996)
  77.   - included getopt.c in distribution, changed option handling
  78.   - prepared readjpeg.c for use with jpeg2pdf program (accept baseline only)
  79.   - included jpeg2pdf in the distribution
  80.  
  81. V1.3 (Jan. 31, 1996)
  82.   - Fixed ASCII85 encoding bug. In rare cases ~ and > could get
  83.     separated.
  84.  
  85. V1.2 (Jan. 25, 1996) 
  86.   - Fixed "unsigned" bug when reading JFIF density marker.
  87.  
  88. V1.1 (Jan. 22, 1996) Several enhancements:
  89.   - invert colors of Adobe Photoshop CMYK files
  90.   - interpret JFIF resolution ("density") markers
  91.   - implemented -r switch for specifying resolution 
  92.   - accept compression markers other than SOF0 and SOF1 (this won't
  93.     be useful for many people, and didn't have any testing).
  94.  
  95. V1.0 (Jan. 9, 1996) Re-release of formerly released Usenet version.
  96.  
  97.  
  98. Building JPEG2PS
  99. ================
  100. jpeg2ps is coded in rather simple-minded ANSI C. It should compile cleanly
  101. on many systems. For old K&R compilers, include the compiler flag -DKNR in 
  102. the makefile to disable ANSI prototypes.
  103.  
  104. The jpeg2ps distribution is available in .zip and .tar.gz format.
  105. jpeg2ps-x.x.zip is intended for MS-DOS (real or DOS box in Windows)
  106. and also includes an executable. Source code is identical in both 
  107. jpeg2ps-x.x.zip and jpeg2ps-x.x.tar.gz, the only exception being different
  108. line end conventions.
  109.  
  110. General compilation options
  111. ---------------------------
  112. -DA4 makes jpeg2ps use A4 as default paper size. If -DA4 is not
  113. given, letter format will be used instead. Note that the paper
  114. size can always be specified at the command line.
  115.  
  116. Unix
  117. ----
  118. jpeg2ps should compile out of the box on most Unix systems,
  119. probably after a little Makefile tweaking. The distributed
  120. Makefile is set up for GCC on Linux.
  121.  
  122. DOS
  123. ---
  124. Use -DDOS to compile jpeg2ps on DOSish systems. The distributed
  125. source builds fine with MS Visual C++ 6.0. A project file for
  126. this environment is included in the distribution.
  127.  
  128. OS/2
  129. ----
  130. OS/2 support was provided by Stefan A. Deutscher (sad@utk.edu / stefand@ibm.net)
  131. and is included in the distribution "as is", i.e., I'm unable to assist in
  132. any OS/2-related issues. The following is from Stefan's description for OS/2:
  133.  
  134. >The executable was made from the unmodified unix sources with gcc / emx09c +
  135. >emxfix2 applied. To run it you need the emx runtime system, which you
  136. >find as emxrt.zip, or on ftp-os2.cdrom.com or ftp-os2.nmsu.edu or ftp.leo.org.
  137. >Newer versions than emx09c+ef2 should be fine. I tested this only on Warp 4,
  138. >and there it works.
  139.  
  140. Mac
  141. ---
  142. jpeg2ps can be built on the Mac using a facility called DropUNIX. This is
  143. a wrapper for conventional command-line driven Unix programs which gives
  144. some sort of drag-and-drop support. However, command line options are
  145. not available. For this reason, jpeg2ps always generates ASCII85 output
  146. if built on the Mac.
  147.  
  148. In order to build jpeg2ps on the Mac, you will need DropUNIX from
  149. http://www.zenspider.com or some mirror, such as
  150. http://omlc.ogi.edu/software/tex_convert
  151.  
  152. and set the C preprocessor define -DMAC. Since the MetroWerks compiler
  153. has a somewhat kludgey way to set preprocessor options, the file
  154. prefix-mac.pch is supplied which should be added to the project as
  155. a precompiled header (see MW docs).
  156.  
  157. The idea for the Mac port and the DropUNIX support were provided by 
  158. Ujwal Sathyam (setlur@bigfoot.com).
  159.  
  160. Although I successfully built jpeg2ps with the MetroWerks compiler,
  161. Mac support is still somewhat experimental. The required build
  162. files are not included in the distribution. (No, please don't ask me for
  163. an executable).
  164.  
  165. Note that for unknown reason the Mac version currently supports only
  166. conversion of single files. Although it seems to work with multiple
  167. files too, the output generated for the second and subsequent files
  168. will be rubbish.
  169.  
  170.  
  171. VMS
  172. ---
  173. A VMS build file was provided by Rolf Niepraschk (niepraschk@ptb.de). It isn't
  174. supported by the author of this software. Use the supplied file "descrip.mms"
  175. as a starting point for building jpeg2ps with the VMS build tool mms.
  176.  
  177.  
  178. Usage Details
  179. =============
  180. jpeg2ps [options] file.jpg > file.eps
  181.  
  182. -a       auto rotate feature
  183. -b       binary mode
  184. -h       hex mode (ASCIIHex encoding)
  185. -o name  output file name (as an alternative to output redirection)
  186. -p size  page size name. Known names are:
  187.          a0, a1, a2, a3, a4, a5, a6, b5, letter, legal, ledger, p11x17
  188. -q       quiet mode: suppress all informational messages
  189. -r dpi   resolution value (0 = read from file if possible)
  190.  
  191. jpeg2ps reads a JPEG file (*not* stdin) and writes a DSC-compliant EPS
  192. file containing the compressed JPEG data in PostScript format to stdout.
  193. The produced EPS files contain the necessary DSC comments including 
  194. BoundingBox, so they may be imported in page layout applications. However,
  195. they do not contain preview images, so you will only see a gray box on screen.
  196.  
  197. If the auto rotate feature is activated with the -a option, images with
  198. width > height are automatically rotated to landscape mode. Don't use this
  199. option if you simply want to generate EPS files for inclusion in your
  200. documents. Note: prior to version 1.6, jpeg2ps always "autorotated" images
  201. with width > height which was especially bad for TeX users. I hope this
  202. change helps the TeX community in better using jpeg2ps!
  203.  
  204. jpeg2ps performs some sanity checks with the JPEG data. It detects several
  205. kinds of corrupt input data, but it is not absolutely foolproof. One special
  206. feature is that you can feed Macintosh JPEG files (PICT-JPEG) to jpeg2ps. 
  207. These normally have several hundred bytes of additional stuff before the JPEG 
  208. data. This PICT rubbish is simply ignored by jpeg2ps.
  209.  
  210.  
  211. Output modes
  212. ============
  213. By default, jpeg2ps sends the image data in ASCII85 encoded form which is
  214. suitable for any communication channel (serial, parallel or whatever). If
  215. you are *sure* that your channel is truly 8-bit clean, you can force 8-bit
  216. data with the -b option. Note that this normally does not apply to 8-bit
  217. serial or even parallel channels since some control characters are reserved
  218. for the communications protocol. You can use binary data e.g.:
  219.  
  220. - with some networked printers
  221. - with direct-access PostScript interpreters, e.g. Ghostscript
  222. - serial or parallel channels using Binary Control Protocol (BCP).
  223.  
  224. Using the -h option, jpeg2ps generates 7-bit clean data by using
  225. ASCIIHex encoding instead of the more space-efficient ASCII85 encoding.
  226. This is only useful for specialized applications, e.g. for debugging,
  227. since jpeg2ps requires PostScript Level 2 anyway, and ASCII85 is
  228. supported in any Level 2 interpreter.
  229.  
  230.  
  231. Scaling and resolution
  232. ======================
  233. Concerning the size of the printed image, you have three options:
  234.  
  235. Default behaviour:
  236. By default, doesn't change the image size and rotation.
  237. With the -a option, jpeg2ps tries to fit the image on the page, rotating
  238. it if necessary (image width exceeds image height)
  239. The image is scaled in a way to use at least one full edge of the paper.
  240. A 20 pt margin is subtracted on each side. "Page" means A4 size if compiled 
  241. with "-DA4", letter size otherwise. The -p option may be used to select
  242. other page sizes.
  243.  
  244. Using resolution value from the file:
  245. The option "-r 0" instructs jpeg2ps to look for a JFIF density/resolution
  246. marker and use that value. Automatic scaling and rotation are disabled.
  247. However, if no resolution information is found in the file, jpeg2ps
  248. applies the default algorithm described above.
  249.  
  250. Explicitly setting the resolution:
  251. Using "-r <dpi>" you can force jpeg2ps to use a certain dpi value. 
  252. Since automatic actions are also disabled in this case, you are 
  253. responsible for choosing a reasonable resolution value.  For example, 
  254. you can print a 300 dpi image half-sized by supplying -r 600.
  255.  
  256.  
  257. Messages
  258. ========
  259. jpeg2ps issues three kinds of messages:
  260.  
  261. Notes:    have informational character
  262.  
  263. Warnings: a potential problem with the file was recognized, processing
  264.       continues.
  265.  
  266. Errors:   Either a severe problem within the JPEG file was found or the
  267.           file explores JPEG features not compatible with PostScript Level 2.
  268.  
  269. Note that there are some JPEG producers which do not exactly conform to the
  270. specification and that the JPEG spec itself does not cover every aspect of
  271. the file format. You are on the safe side if you demand JFIF files which are
  272. happily accepted by jpeg2ps. (For further information see the JPEG FAQ
  273. by Tom Lane.)
  274.  
  275.  
  276. Adobe Photoshop CMYK files
  277. ==========================
  278. This is what the Independent JPEG Group has to say about Photoshop
  279. CMYK files (quoted from libjpeg.doc, part of the IJG JPEG library):
  280.  
  281. > CAUTION: it appears that Adobe Photoshop writes inverted data in CMYK JPEG
  282. > files: 0 represents 100% ink coverage, rather than 0% ink as you'd expect.
  283. > This is arguably a bug in Photoshop, but if you need to work with Photoshop
  284. > CMYK files, you will have to deal with it in your application.  We cannot
  285. > "fix" this in the library by inverting the data during the CMYK<=>YCCK
  286. > transform, because that would break other applications, notably Ghostscript.
  287. > Photoshop versions prior to 3.0 write EPS files containing JPEG-encoded CMYK
  288. > data in the same inverted-YCCK representation used in bare JPEG files, but
  289. > the surrounding PostScript code performs an inversion using the PS image
  290. > operator.  I am told that Photoshop 3.0 will write uninverted YCCK in
  291. > EPS/JPEG files, and will omit the PS-level inversion.  (But the data
  292. > polarity used in bare JPEG files will not change in 3.0.)  In either case,
  293. > the JPEG library must not invert the data itself, or else Ghostscript would
  294. > read these EPS files incorrectly.
  295.  
  296. Accordingly, jpeg2ps tries to detect such files (by looking for Adobes
  297. APP marker) and inverts the colors in the case of 4-component images.
  298. This inversion takes place in the PostScript instructions, not by
  299. changing the actual image data.
  300.  
  301.  
  302. Further Information
  303. ===================
  304.  
  305. If you like to know more about the inner workings of jpeg2ps, the JPEG
  306. standard and its integration in PostScript Level 2, the JFIF file format,
  307. JPEG/TIFF *and* if you can read German, you may want to check out 
  308. my article in a German computer magazine:
  309.  
  310. "Gut verpackt - Drucken von JPEG-Bildern mit PostScript Level 2"
  311. c't, Magazin fuer Computertechnik, Heise Verlag Hannover, 6/94, p.236 ff.
  312.  
  313. This article is also available in PDF format from my WWW page:
  314. http://www.ifconnection.de/~tm
  315.  
  316.  
  317. Related Software
  318. ================
  319.  
  320. Note that there is a related PostScript program called "viewjpeg.ps" which
  321. is part of the Ghostscript distribution. viewjpeg.ps operates similarly to
  322. jpeg2ps, but the PostScript interpreter does the "wrapping" of JPEG data
  323. itself. With viewjpeg.ps you can e.g. view JPEG files directly within 
  324. GhostScript or another interpreter with access to the file system.
  325. Ghostscript can be found at http://www.cs.wisc.edu/~ghost
  326.  
  327.  
  328. Disclaimer 
  329. ==========
  330. This software is free. You are granted the right to use and copy it. This
  331. software may not be sold or bundled with any commercial package without
  332. express written permission of the author. 
  333.  
  334. The author accepts no responsibility for damages resulting from the use of
  335. this software and makes no warranty, either express or implied, including but
  336. not limited to, any implied warranty of merchantability or fitness for a
  337. particular purpose. This software is provided as is, and you assume all risks
  338. when using it. 
  339.